/**
 * Project: happyouting-dal-activity
 * 
 * File Created at 2009-11-4
 * $Id: IbatisActivityApplyDao.java 102 2009-11-22 08:44:27Z worldmaomao $
 * 
 * Copyright 2008 Alibaba.com Croporation Limited.
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of
 * Alibaba Company. ("Confidential Information").  You shall not
 * disclose such Confidential Information and shall use it only in
 * accordance with the terms of the license agreement you entered into
 * with Alibaba.com.
 */
package com.alibaba.happyouting.activity.dal.dao.ibatis;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

import com.alibaba.happyouting.activity.dal.dao.ActivityApplyDao;
import com.alibaba.happyouting.activity.dal.dataobject.ActivityApply;
import com.alibaba.happyouting.activity.dal.dataobject.ActivityApplyWithUserName;

/**
 * TODO Comment of IbatisActivityApplyDao
 * 
 * @author xingyue.wangxy
 */
public class IbatisActivityApplyDao extends SqlMapClientDaoSupport implements ActivityApplyDao {



    public void insertActivityApply(ActivityApply activityApply) {
        this.getSqlMapClientTemplate().insert("insertActivityApply", activityApply);
    }

    public void updateActivityApply(ActivityApply activityApply) {
        this.getSqlMapClientTemplate().update("updateActivityApply", activityApply);
    }

    public void deleteActivityApply(Long id, Long uid) {
        Map map = new HashMap();
        map.put("id", id);
        map.put("uid", uid);
        this.getSqlMapClientTemplate().delete("deleteActivityApply", map);
    }

    public Integer getCountOfActivityJoin(Long id) {
        return (Integer)this.getSqlMapClientTemplate().queryForObject("getCountOfActivityJoin", id);
    }

    public void deleteActivityApplyByActivityId(Long id) {
        this.getSqlMapClientTemplate().delete("deleteActivityApplyByActivityId", id);
    }


    public List<ActivityApplyWithUserName> findActivityApplyOfActivity(Long id, Integer start, Integer size, Integer status){
        Map map = new HashMap();
        map.put("id", id);
        map.put("start", start);
        map.put("size", size);
        map.put("status", status);
        return this.getSqlMapClientTemplate().queryForList("findActivityApplyOfActivity", map);
    }


    public void updateActivityApplyStatusToPass(List<Long> userIdList, Long activityId) {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("userIdList", userIdList);
        map.put("activityId", activityId);
        this.getSqlMapClientTemplate().update("updateActivityApplyStatusToPass", map);
    }
    
    public void updateActivityApplyStatusToDeny(List<Long> userIdList, Long activityId) {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("userIdList", userIdList);
        map.put("activityId", activityId);
        this.getSqlMapClientTemplate().update("updateActivityApplyStatusToDeny", map);
    }
    
    public void updateActivityApplyStatusToStart(List<Long> userIdList, Long activityId) {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("userIdList", userIdList);
        map.put("activityId", activityId);
        this.getSqlMapClientTemplate().update("updateActivityApplyStatusToStart", map);
    }

    public List<ActivityApply> findActivityApply(Long id, Long uid, List<Integer> statusList) {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("statusList", statusList);
        map.put("id", id);
        map.put("uid", uid);
        return this.getSqlMapClientTemplate().queryForList("findActivityApply", map);
    }


    public Integer getCountOfActivityApply(Long id, Long uid, List<Integer> statusList) {   
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("statusList", statusList);
        map.put("id", id);
        map.put("uid", uid);
        return (Integer) this.getSqlMapClientTemplate().queryForObject("getCountOfActivityApply", map);
    }
    

    public Integer getCountOfActivityApplyOfActivity(Long id, Integer status) {
        Map map = new HashMap();
        map.put("id", id);
        map.put("status", status);
        return (Integer) this.getSqlMapClientTemplate().queryForObject("getCountOfActivityApplyOfActivity", map);
    }


    public void deleteActivityApplyByActivityIdAndUserIds(Long activityId, List<Long> userIdList) {
        Map map = new HashMap();
        map.put("activityId", activityId);
        map.put("useridList", userIdList);
        this.getSqlMapClientTemplate().delete("deleteActivityApplyByActivityIdAndUserIds", map);
    }




}
